﻿//======================= Namespace =======================\\
/*
##################### Do Not Remove This Header #####################
#                                                                   #
# Title: Namespace                                                  #
# Description: A function for simulating namespaces in javascript.  #       
# Author: Adam Smith                                                #
# Date Created: May 10, 2007                                        #
# Website: codevendor.com                                           #
# License: Free to use for personal or commercial use as long as    #
#          header stays in place.                                   #
#                                                                   #
#####################################################################
*/

var Namespace = {
    
    Register : function(_Name)
    {
        var chk = false;
        var cob = "";
        var spc = _Name.split(".");
        for(var i = 0; i<spc.length; i++)
        {
            if(cob!=""){cob+=".";}
            cob+=spc[i];
            chk = this.Exists(cob);
            if(!chk){this.Create(cob);}
        }
        
        if(chk){ throw "Namespace: " + _Name + " is already defined."; }
    },
    
    Create : function(_Src)
    {
        eval("window." + _Src + " = new Object();");
    },
    
    Exists : function(_Src)
    {
        eval("var NE = false; try{if(" + _Src + "){NE = true;}else{NE = false;}}catch(err){NE=false;}"); 
        return NE;
    }
}
//======================= End Namespace =======================\\